#include "Subject.h"
#include "Observer.h"

Subject::Subject()
{
	_obvs = new list<Observer*>;
}

Subject::~Subject() 
{
	delete _obvs;
}

void Subject::Attach(Observer* obs)
{
	_obvs->push_front(obs);
}

void Subject::Detach(Observer* obs)
{
	if (obs)
	{
		_obvs->remove(obs);
	}
}

void Subject::Notify()
{
	list<Observer*>::iterator it = _obvs->begin();

	for (; it != _obvs->end(); ++it)
	{
		(*it)->Update(this);
	}
}

ImageSubject::ImageSubject()
{
	_stat = '\0';
}

ImageSubject::~ImageSubject()
{

}

void ImageSubject::SetState(const State& stat)
{
	_stat = stat;
}

State ImageSubject::GetState()
{
	return _stat;
}